In multi-threading computing systems, multiple threads may need access to a shared resource. Some shared resources (e.g., a database) cannot be accessed simultaneously or changes made to the shared resource may not be properly recorded. Accordingly, the shared resource may be “locked” during use to prevent simultaneous access.
Multi-processor environments implement a “spin-lock” procedure wherein a processor waiting for a shared resource lock to be released by another processor repeatedly checks the lock status. However, the spin-lock procedure is inefficient in a multi-threading environment where a thread waiting for a shared resource lock to be released may block processing resources for other threads executing on the same processor.
The thread may yield processing resources to another thread while waiting for a resource lock to be released. However, the other thread may dominate the processing resources, preventing the yielding thread from checking the lock status for the shared resource. When the processing resources are finally returned to the yielding thread, the shared resource may already be locked by another processor.